/**
 * Created with Intellij IDEA
 * Description
 * User:ASUS
 * Date:2024-08-07
 * Time:21:40
 */
class Login{
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public void logInfo(String userName, String passWord) throws UserNameException,PassWordException {
        if(!this.userName.equals(userName)){
            throw new UserNameException("用户名错误异常");
        }
        if(!this.passWord.equals(passWord)){
            throw new PassWordException("密码错误异常");
        }
        System.out.println("登陆成功");
        System.out.println();
    }
}
public class Test {
    public static void main(String[] args) {
        Login login=new Login();
        login.setUserName("xiaoyi");
        login.setPassWord("123");
        login.logInfo("xiaoyi1","123");
        try{
            login.logInfo("xiaoyi1","123");
        }catch (UserNameException e){
            e.printStackTrace();
        }catch (PassWordException e){
            e.printStackTrace();
        }
    }
}